import React from 'react'
import mirror, { connect, Router, Route, Link, Switch } from 'mirrorx'
import Bundle from './lib/bundle.js'

import NoMatch from './pages/404'
import Empty from './pages/empty'
import Home from 'bundle-loader?lazy!./pages/home'

import Nav from './nav'
import Login from './pages/user/login'
import Register from './pages/user/register'
import RegisterSuccess from './pages/user/registerSuccess'

import InfoMain from './pages/user/info/info-main'
import InfoBase from './pages/user/info/info-base'
import InfoCertificate from './pages/user/info/info-certificate'

import PasswordManage from './pages/user/password/password-manage'
import PasswordForget from './pages/user/password/password-forget'
import PasswordReset from './pages/user/password/password-reset'
import PasswordSet from './pages/user/password/password-set'

import BankcardList from './pages/user/bankcard/bankcard-list'
import BankcardManage from './pages/user/bankcard/bankcard-manage'
import BankcardInfo from './pages/user/bankcard/bankcard-info'
import BankcardVerify from './pages/user/bankcard/bankcard-verify'
import BankcardCreditcard from './pages/user/bankcard/bankcard-creditcard'

import SurrenderCompose from './pages/surrender/surrender-compose'
import SurrenderDetail from './pages/surrender/surrender-detail'
import SurrenderPayway from './pages/surrender/surrender-payway'
import SurrenderSuccess from './pages/surrender/surrender-success'

import InsurePoc from './pages/poc-yahu/insure'
import ProductListPoc from './pages/poc-yahu/product-list'
import ProductDetailPoc from './pages/poc-yahu/product-detail'
import PayPoc from './pages/poc-yahu/pay'
import SuccessPoc from './pages/poc-yahu/success'

import InsureYJ from './pages/poc-YJ/insure/index'
import ProductListYJ from './pages/poc-YJ/product-list'
import ProductDetailYJ from './pages/poc-YJ/product-detail/index'
import PayYJ from './pages/poc-YJ/pay'
import SuccessYJ from './pages/poc-YJ/success'
import PolicyListYJ from './pages/poc-YJ/policy/policy-list'
import PolicyDetailYJ from './pages/poc-YJ/policy/policy-detail'
import SurrenderSuccessYJ from './pages/poc-YJ/policy/surrender-success'

import InsureYJen from './pages/poc-YJ-en/insure/index'
import ProductListYJen from './pages/poc-YJ-en/product-list'
import ProductDetailYJen from './pages/poc-YJ-en/product-detail/index'
import PayYJen from './pages/poc-YJ-en/pay'
import SuccessYJen from './pages/poc-YJ-en/success'
import PolicyListYJen from './pages/poc-YJ-en/policy/policy-list'
import PolicyDetailYJen from './pages/poc-YJ-en/policy/policy-detail'
import SurrenderSuccessYJen from './pages/poc-YJ-en/policy/surrender-success'

import PocClaimRequest from './pages/poc-grab-claim/step1'
import PocClaimUpload from './pages/poc-grab-claim/step2'
import PocClaimSuccess from './pages/poc-grab-claim/step3'

import CarInsurance from './pages/car-insurance/index'
import CarInsuranceDetail from './pages/car-insurance/detail'

import Grablist from './pages/poc-grab/grab-list'

const Homepage = () => (
  <Bundle load={Home}>
    {(Component) => <Component />}
  </Bundle>
)

const routes = (
  <Switch>
    <Route exact path='/' component={Login} />
    <Route exact path='/home' component={Homepage} />
    <Route exact path='/nav' component={Nav} />

    <Route exact path='/login' component={Login} />
    <Route exact path='/register' component={Register} />
    <Route exact path='/registerSuccess' component={RegisterSuccess} />

    <Route exact path='/info-base' component={InfoBase} />
    <Route exact path='/info-main' component={InfoMain} />
    <Route exact path='/info-certificate' component={InfoCertificate} />

    <Route exact path='/password-manage' component={PasswordManage} />
    <Route exact path='/password-forget' component={PasswordForget} />
    <Route exact path='/password-reset' component={PasswordReset} />
    <Route exact path='/password-set' component={PasswordSet} />

    <Route exact path='/surrender-compose' component={SurrenderCompose} />
    <Route exact path='/surrender-detail' component={SurrenderDetail} />
    <Route exact path='/surrender-payway' component={SurrenderPayway} />
    <Route exact path='/surrender-success' component={SurrenderSuccess} />

    <Route exact path='/bankcard-list' component={BankcardList} />
    <Route exact path='/bankcard-manage' component={BankcardManage} />
    <Route exact path='/bankcard-info' component={BankcardInfo} />

    <Route exact path='/bankcard-verify' component={BankcardVerify} />
    <Route exact path='/bankcard-creditcard' component={BankcardCreditcard} />

    <Route exact path='/insure-poc' component={InsurePoc} />
    <Route exact path='/product-detail-poc' component={ProductDetailPoc} />
    <Route exact path='/product-list-poc' component={ProductListPoc} />
    <Route exact path='/pay-poc' component={PayPoc} />
    <Route exact path='/success-poc' component={SuccessPoc} />
    <Route exact path='/grab-list' component={Grablist} />

    <Route exact path='/insure-yj' component={InsureYJ} />
    <Route exact path='/product-detail-yj' component={ProductDetailYJ} />
    <Route exact path='/product-list-yj' component={ProductListYJ} />
    <Route exact path='/pay-yj' component={PayYJ} />
    <Route exact path='/success-yj' component={SuccessYJ} />
    <Route exact path='/policy-list-yj' component={PolicyListYJ} />
    <Route exact path='/policy-detail-yj' component={PolicyDetailYJ} />
    <Route exact path='/surrender-success-yj' component={SurrenderSuccessYJ} />

    <Route exact path='/insure-yj-en' component={InsureYJen} />
    <Route exact path='/product-detail-yj-en' component={ProductDetailYJen} />
    <Route exact path='/product-list-yj-en' component={ProductListYJen} />
    <Route exact path='/pay-yj-en' component={PayYJen} />
    <Route exact path='/success-yj-en' component={SuccessYJen} />
    <Route exact path='/policy-list-yj-en' component={PolicyListYJen} />
    <Route exact path='/policy-detail-yj-en' component={PolicyDetailYJen} />
    <Route exact path='/surrender-success-yj-en' component={SurrenderSuccessYJen} />

    //理赔流程
    <Route exact path='/poc-claim' component={PocClaimRequest} />
    <Route exact path='/poc-claim-upload' component={PocClaimUpload} />
    <Route exact path='/poc-claim-success' component={PocClaimSuccess} />

    {/* 车险demo */}
    <Route exact path='/car-insurance' component={CarInsurance} />
    <Route exact path='/car-insurance-detail' component={CarInsuranceDetail} />

    <Route path='/empty' component={Empty} />
    <Route component={NoMatch} />
  </Switch>
)
class App extends React.Component {
  shouldComponentUpdate () {
    return false
  }

  componentDidMount () {
    // console.log("router...")
  }

  render () {
    return (
      <Router forceRefresh={!('pushState' in window.history)}>
        {routes}
      </Router>
    )
  }
}

export default App
